#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
typedef long long LL;
map<int, int>mp;
int n;
LL ans;
int main()
{
	cin >> n;
	ans = 1ll * (n - 1) * n;
	ans /= 2;
	//cout<<"ans=="<<ans<<endl;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	for (auto item : mp) {
		int x = item.first, y = item.second;
		if (mp[x] >= 2) {
			LL ans1 = 1ll * (mp[x] - 1) * mp[x];
			ans1 /= 2;
			ans -= ans1;
		}
	}
	cout << ans << endl;
	return 0;
}